<?php
require_once '../includes/constants.php';
require_once '../includes/usuario.php';
$usuario = new usuario();
$resultado = false;

if (isset($_POST['enviar'])) {
    $resultado = $usuario->recuperar_clave($_POST['email']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Recuperar Contraseña</title>
        <link href="../css/style.css" media="all" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="../js/jquery-validate/jquery.validate.min.js"></script>
        <script type="text/javascript" src="../js/jquery-validate/localization/messages_es.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $("#form1").validate({});
            });
        </script>
    </head>
    <body>
        <div id="header">
            <?php include '../template/header.php'; ?>
        </div>
        <div id="content">
            <?php if (!$resultado['exito']): ?>
                <?php if (isset($_POST['enviar'])): ?>
                    <p class="error"><?php echo $resultado['mensaje']; ?></p>
                <?php endif; ?>
                <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form1" id="form1" enctype="multipart/form-data">
                    <fieldset>
                        <legend>Introduzca su correo electrónico</legend>
                        <div>
                            <label for="email">Email:</label>
                            <input type="text" class="required email" name="email"/>
                        </div>
                        <div>
                            <input type="submit" name="enviar" value="Recuperar Contraseña"/>
                        </div>
                    </fieldset>
                </form>
            <?php else: ?>
                <div class="info">
                    <p>Se ha enviado su contraseña a su correo electrónico.</p>
                </div>
            <?php endif; ?>
        </div>
        <div id="footer">
            <?php include '../template/footer.php'; ?>
        </div>
    </body>
</html>
